//
//  QCUserAccountModel.swift
//  SwiftDemoWithSina
//
//  Created by qu on 2017/2/4.
//  Copyright © 2017年 Apple. All rights reserved.
//

import UIKit
//用户信息的模型
class QCUserAccountModel: NSObject,NSCoding {
    //用户授权的唯一票据
    var access_token: String?
    
    var expires_in: Double = 0{
        
        didSet{
            
            expires_Date = Date(timeIntervalSinceNow: expires_in)
            
        }
        
    }
    /// 授权用户的UID
    var uid: String?
    /// 用户昵称
    var screen_name: String?
    /// 用户头像
    var avatar_large: String?
    /// access_token 过期的日期(会员过期时间为5年 普通用户为3天)
    var expires_Date: Date?
    
   override init() {
        super.init()
    }
    //归档
    func encode(with aCoder: NSCoder) {
        self.yy_modelEncode(with:aCoder)
    }
    //解档
    required init?(coder aDecoder: NSCoder) {
        super.init()
        self.yy_modelInit(with: aDecoder)
    }
    //重写description方法
    override var description: String{
        let keys = ["access_token", "expires_Date", "uid", "screen_name", "avatar_large"]
        return dictionaryWithValues(forKeys: keys).description
        
    }
    
}
